﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QRCodePass.Core.Models;

namespace QRCodePass.EntityFrameworkCore.EntityMapper
{
    public class StudentProcessMapper : IEntityTypeConfiguration<StudentProcess>
    {
        public void Configure(EntityTypeBuilder<StudentProcess> builder)
        {
            //修改表名为Enrollment，设置StudentCourseId为主键Id
            builder.ToTable("ProcessRecord", "QRCodePass").HasKey(a => a.RecordId);

            //StudentCourses关联实体Student，设置外键id为StudentID
            builder.HasOne(a => a.Student).WithMany(a => a.StudentProcesses).HasForeignKey(a => a.StudentId);
            builder.HasOne(a => a.Process).WithMany(a => a.StudentProcesses).HasForeignKey(a => a.ProcessId);
        }
    }
}